package com.hi.hiparty.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.hi.hiparty.R;
import com.hi.hiparty.ui.session.UserSession;
import com.hi.hiparty.ui.session.UserSessionManager;

public class UserEntranceActivity extends Activity {

	private static final String TAG = "UserEntranceActivity";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		UserSession session = UserSessionManager.getUserSession(this);
		if (null != session) {
			Intent intent = new Intent(UserEntranceActivity.this, MainActivity.class);
			Bundle bundle = new Bundle();
			bundle.putString("userid", session.getUserid());
			intent.putExtras(bundle);
			startActivity(intent);
			return;
		}

		setContentView(R.layout.activity_userentrance);

		Button loginButton = (Button) findViewById(R.id.btn_login);
		loginButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				Intent intent = new Intent(UserEntranceActivity.this, LoginActivity.class);
				startActivity(intent);
			}

		});

		Button regButton = (Button) findViewById(R.id.btn_register);
		regButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				Intent intent = new Intent(UserEntranceActivity.this, RegisterActivity.class);
				startActivity(intent);
			}

		});

	}

}
